package com.chb.controller;

import com.chb.annotation.LogAnnotation;
import com.chb.model.vo.BranchAllGoodsVo;
import com.chb.model.vo.Result;
import com.chb.service.BranchGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: 陈海彬
 * @date: Created in 2023/9/27 9:26
 * @description:
 * @modified By:
 * @version:
 */
@RestController
@RequestMapping("/branchGoods")
public class BranchGoodsController {
    @Autowired
    private BranchGoodsService branchGoodsService;

    /**
     * @param page     当前页数
     * @param pageSize 每页展示的最大值
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 获取新增入库的所有商品信息
     * @create time: 2023/9/27 9:28
     */
    @GetMapping("/getAllShoping")
    public Result getAllShoping(Integer page, Integer pageSize) {
        Result result = branchGoodsService.selectBranchGoodsById(page, pageSize);
        return result;
    }

    /**
     * @param id 入库id
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 审核通过添加商品数量
     * @create time: 2023/9/27 16:27
     */
    @PostMapping("/updateShoing")
    @LogAnnotation(business_type = "入库审核，审核通过")
    public Result updateShoping(Integer id) {
        return branchGoodsService.updateShoping(id);
    }

    /**
     * @param branchAllGoodsVos
     * @return com.chb.model.vo.Result
     * @create by: 陈海彬
     * @description: 向分店添加商品
     * @create time: 2023/9/27 20:37
     */
    @PostMapping("/addBranchGoods")
    public Result addBranchGoods(@RequestBody List<BranchAllGoodsVo> branchAllGoodsVos) {
        return branchGoodsService.addBranchGoods(branchAllGoodsVos);
    }
}